<template>
  <div class="about-master-container">
    <base-breadcrumb>
      <searchData :search-data="searchArr" @search="search" />
      <a-card :bordered="false">
        <!-- <title-name>潜亏风险</title-name> -->
        <list-table
          ref="table"
          :columns="columns"
          :request="loadData"
          :exportConfig="{use:true, select: '潜亏风险',all: '潜亏风险'}"
        >
          <span slot="index" slot-scope="text, record, index">{{ index + 1 }}</span>
          <template slot="operation" slot-scope="text, record">
            <div class="pub-table-list-action">
              <span
                v-btn-permission="'lcm_012_loo_01'"
                @click="$nav('/businessAffairs/updateCostAnalysisAudit',{id:record.id,pageType:'look'})"
              >查看</span>
              <!--              <span v-if="record.converterStatusStr === '未转化'"-->
              <!--                    v-btn-permission="'lcm_012_zhh_02'"-->
              <!--                    @click="$nav('/legal/risk/list/add',{hideLossId:record.id})"-->
              <!--              >转化为风险</span>-->
              <span
                v-if="record.converterStatusStr === '未转化'&&hideBuquBtn()"
                @click="transfer(record)"
              >转化为风险</span>
            </div>
          </template>
        </list-table>
      </a-card>
    </base-breadcrumb>
  </div>
</template>

<script>
import SelectSubCompany from '@/components/Select/SelectSubCompany'
import SelectProject from '@/components/Select/SelectProject'
import OrgTreeSelect from '@/components/OrgTreeSelect'
import riskListApi from '@/api/legal/risk/list'

export default {
  name: 'HideLossIndex',
  data() {
    return {
      columns: [
        { title: '序号', dataIndex: 'index', width: 70, scopedSlots: { customRender: 'index' } },
        { title: '所属分公司', dataIndex: 'branchComName', width: 170 },
        { title: '项目名称', dataIndex: 'projectName', width: 220 },
        { title: '月份', dataIndex: 'monthDate', width: 100 },
        { title: '工程计量确权(不含税)(万元)', dataIndex: 'confirmationRight', width: 220 },
        { title: '截止目前项目实际产值(不含税)(万元)', dataIndex: 'projectActOutPutValueSoFar', width: 270 },
        { title: '截止目前项目实际成本(不含税)(万元)', dataIndex: 'projectActCostSoFar', width: 270 },
        { title: '工程计量确认率(%)', dataIndex: 'confirmationRate', width: 200 },
        { title: '状态', dataIndex: 'converterStatusStr', width: 100 },
        {
          title: '操作',
          width: 150,
          fixed: 'right',
          scopedSlots: { customRender: 'operation' }
        }
      ],
      searchArr: [
        {
          name: '所属单位',
          valueKey: 'searchQuery',
          type: OrgTreeSelect,
        },
        // {
        //   name: '分公司',
        //   valueKey: 'branchComId',
        //   type: SelectSubCompany
        // },
        // {
        //   name: '项目名称',
        //   type: SelectProject,
        //   valueKey: 'projectId',
        //   keyValue: 'branchComId'
        // },
        {
          name: '月份',
          type: 'month',
          value: 'monthDate',
          attrs: {
            valueFormat: 'YYYY-MM'
          }
        },
        {
          name: '状态',
          type: 'select',
          value: 'confirmationRateType',
          data: [
            { label: '未转化', value: 0 },
            { label: '已转化', value: 1 }
          ]
        }
      ],
      loadData: p => riskListApi.legalFindList(Object.assign({}, p, this.queryParam)),
      queryParam: {} // 搜索参数集
    }
  },
  methods: {
    search(val = {}) {
      this.queryParam = val
      this.$refs.table.refresh()
    },
    transfer(row) {
      let hideLossId = row.id
      delete row.id
      row.confirmationRight = row.confirmationRight || ''
      row.projectActOutPutValueSoFar = row.projectActOutPutValueSoFar || ''
      row.projectActCostSoFar = row.projectActCostSoFar || ''
      row.confirmationRate = row.confirmationRate || ''
      this.$nav('/legal/risk/list/add',
        {
          ...row,
          hideLossId
        })
    }
  }
}
</script>
